﻿#include <iostream>

#include "multicast_acceptor.hpp"

void onData(const std::vector<uint8_t>& data, const std::string& ip, uint16_t port)
{
    std::string str(data.begin(), data.end());
    std::cout << "receive data from: " << ip << "::" << port << ", byte num: " << data.size() << ", content: " << str << std::endl;
}


int main()
{
    MulticastAcceptor acceptor{onData};

    if (acceptor.init(5555, "224.1.1.100", "192.168.1.10") == false)
    {
        std::cout << "Failed to init acceptor." << std::endl;
        return -1;
    }
    std::cout << "acceptor init done. " << std::endl;
    acceptor.run();
    acceptor.release();
}
